<?php  

class Controller_Order extends Controller_Website {

    public function action_list() {
        $m_order = Model::factory('order');
        $total = $m_order->count();
        $pager = new Pager($total, 15);
        $order = $m_order->select($pager->offset, $pager->size)->as_array();
        foreach ($order as &$item) {
            $item['price'] = json_decode($item['price'],true);
        }
        
        //获取用户的昵称
        $m_personInfo = Model::factory('personInfo');
        $personInfo = $m_personInfo->getAll()->as_array();
        foreach ($order as &$item) {
            foreach ($personInfo as $item2) {
                if ($item['u_id'] == $item2['uid']) {
                    $item['nick_name'] = $item2['nick_name'];
                }
            }
        }
        
        //获取项目名称
        $m_project = Model::factory('project');
        $project = $m_project->getAll()->as_array();
        foreach ($order as &$item) {
            foreach ($project as $item2) {
                if ($item['project_id'] == $item2['id']) {
                    $item['project_name'] = $item2['project_name'];
                }
            }
        }
//         var_dump($order);exit;
        $this->content = View::factory('order/list');
        $this->content->order = $order;
        $this->content->pager = $pager;
    }

   
}
